From: Matthias Clasen Date: Tue, 4 Oct 2011 18:35:56 +0000 (-0400) Subject: ShellContactSystem: make search terms conjunctive X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~7493 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=492dd718fb426925bfd516bd4a8bf5f6b72e33c1;p=gnome-shell.git ShellContactSystem: make search terms conjunctive Require that all terms match. This is the expected behaviour and matches what gnome-contacts does. Keep the prefix/infix weights in place for now. https://bugzilla.gnome.org/show_bug.cgi?id=660912 --- diff --git a/src/shell-contact-system.c b/src/shell-contact-system.c index fae4898ff..d02c1e26a 100644 --- a/src/shell-contact-system.c +++ b/src/shell-contact-system.c @@ -135,31 +135,52 @@ do_match (ShellContactSystem *self, { const char *term = term_iter->data; const char *p; + gboolean matched; + + matched = FALSE; /* Match on alias, name, nickname */ if (alias != NULL) { p = strstr (alias, term); if (p == alias) - have_name_prefix = TRUE; + { + have_name_prefix = TRUE; + matched = TRUE; + } else if (p != NULL) - have_name_substring = TRUE; + { + have_name_substring = TRUE; + matched = TRUE; + } } if (name != NULL) { p = strstr (name, term); if (p == name) - have_name_prefix = TRUE; + { + have_name_prefix = TRUE; + matched = TRUE; + } else if (p != NULL) - have_name_substring = TRUE; + { + have_name_substring = TRUE; + matched = TRUE; + } } if (nick != NULL) { p = strstr (nick, term); if (p == nick) - have_name_prefix = TRUE; + { + have_name_prefix = TRUE; + matched = TRUE; + } else if (p != NULL) - have_name_substring = TRUE; + { + have_name_substring = TRUE; + matched = TRUE; + } } /* Match on one or more IM or email addresses */ @@ -171,9 +192,15 @@ do_match (ShellContactSystem *self, p = strstr (addr, term); if (p == addr) - have_addr_prefix = TRUE; + { + have_addr_prefix = TRUE; + matched = TRUE; + } else if (p != NULL) - have_addr_substring = TRUE; + { + have_addr_substring = TRUE; + matched = TRUE; + } } g_object_unref (addrs_iter); @@ -184,12 +211,27 @@ do_match (ShellContactSystem *self, p = strstr (addr, term); if (p == addr) - have_addr_prefix = TRUE; + { + have_addr_prefix = TRUE; + matched = TRUE; + } else if (p != NULL) - have_addr_substring = TRUE; + { + have_addr_substring = TRUE; + matched = TRUE; + } } g_object_unref (addrs_iter); + + if (!matched) + { + have_name_prefix = FALSE; + have_name_substring = FALSE; + have_addr_prefix = FALSE; + have_addr_substring = FALSE; + break; + } } if (have_name_prefix)